//
//  YHIMUIKitMessageService.m
//  YHChat
//
//  Created by apple on 2019/4/4.
//  Copyright © 2019 yinhe. All rights reserved.
//

#import "YHIMUIKitMessageService.h"
#import <ImSDK/ImSDK.h>

#import "YHIMUIKitConvCellData.h"

@interface YHIMUIKitMessageService()
@property (nonatomic, strong) YHIMUIKitConvCellData *convData;
@property (nonatomic, strong) TIMConversation *conv;
@property (nonatomic, strong) TIMMessage *lastMsg;
@end

@implementation YHIMUIKitMessageService

- (void)dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (instancetype)initWithConvData:(YHIMUIKitConvCellData *)convData
{
    self = [super init];
    if (self) {
        self.convData = convData;
        
        TIMConversationType type = TIM_SYSTEM;
        if (convData.convType == YHIMUIKitConvType_C2C) {
            type = TIM_C2C;
        } else if (convData.convType == YHIMUIKitConvType_Group) {
            type = TIM_GROUP;
        } else if (convData.convType == YHIMUIKitConvType_System) {
            type = TIM_SYSTEM;
        }
        self.conv = [[TIMManager sharedInstance] getConversation:type receiver:convData.convID];
        
    }
    return self;
}

- (void)loadMessage{
    [self.conv getMessage:YHIMUIKit_MsgCountPerRequest last:self.lastMsg succ:^(NSArray *msgs) {
        
    } fail:^(int code, NSString *msg) {
        
    }];
}


@end
